<!DOCTYPE HTML>
<html style="min-width:inherit;">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script>
window.onload= function(){
	var linkList=window.parent.document.getElementsByTagName("link");//获取父窗口link标签对象列表
	var head=document.getElementsByTagName("head").item(0);
	//外联样式
	for(var i=0;i<linkList.length;i++){
	var l=document.createElement("link");
		l.rel = 'stylesheet'
		l.type = 'text/css'; 
		l.href=linkList[i].href;
		head.appendChild(l);
	}
}
</script>

<script src="/static/www/js/jquery-1.11.1.min.js" type="text/javascript"></script>
<script src="/static/public/layer/layer.js" type="text/javascript"></script>
</head>

<body>

<style>
html,body{ min-width:400px; overflow:visible; background:#FFF;}

.u_pingjia_main{ clear:both; overflow:hidden; background:#f0f0f1; border:1px solid #e4e4e4; border-top:0; padding:0px 30px 0px 30px; line-height:50px;}

.u_pingjia_main .pj_item{ clear:both; overflow:hidden; padding-top:15px;}
.u_pingjia_main .pj_item .fop-label{ float:left; width:100px;}
.u_pingjia_main .pj_item .fop-main{ overflow:hidden;}
.u_pingjia_main .pj_item .Icons_star{ margin-top:-3px; margin-left:20px;}
.u_pingjia_main .pj_item .txtAnum{ border:1px solid #e4e4e4; background:#fff; padding:10px; height:180px; margin-top:10px;}
.u_pingjia_main .pj_item .txtAnum textarea{ width:100%; height:100%; line-height:20px;}
.u_pingjia_main #ceiling{ display:none; color:red;}
.u_pingjia_main .pos_item{ position:relative;}
.u_pingjia_main .pos_item .tsB{ width:50px; float:left;}

/* rater star */
.of_stars { float:left;}

.rater-star{position:relative;list-style:none;margin:0;padding:0;background-repeat:repeat-x;background-position:left top;float:left; line-height:25px;}
.rater-star-item, .rater-star-item-current, .rater-star-item-hover{position:absolute;top:0;left:0;background-repeat:repeat-x;}
.rater-star-item{background-position: -100% -100%;}
.rater-star-item-hover{background-position:0 -50px;cursor:pointer;}
.rater-star-item-current{background-position:0 -50px;cursor:pointer;}

/* popinfo */
.popinfo{display:none; position:absolute; top:50px;background:url(../img/infobox-bg.gif) no-repeat; padding-top:8px; width:192px;}
.popinfo .info-box{border:1px solid #f00; border-top:0;padding:0 5px;color:#F60;background:#FFF;}
.popinfo .info-box div{color:#333;}
.rater-star-result{color:#FF6600;font-weight:bold;padding-left:10px;float:left;}

</style>

<!--star md-->
<div class="u_pingjia_main fs16">
    <div class="pj_item">
        <div class="fop-label">商品满意度</div>
        <div class="fop-main">
            <div id="rate-comm"></div>
        </div>
    </div>
    <div class="pj_item pos_item">
        <div class="fop-label">评价：</div>
        <div class="fop-main">
            <div class="txtAnum"><textarea onkeyup="keyAnum($(this))" name="content" id="content" placeholder="留下你的牛评吧~"></textarea></div>
            <div class="tar l">
            	<input type="submit" id="submit" value="提交" >
            </div>
            <div class="r tar">
                <strong id="ceiling">字数已到上限啦~</strong>
                <span class="c-666666 p-t10">最少10个字，最多可输入500字，你已输入<font id="word">0</font>字</span>
            </div>
        </div>
    </div>
</div>
<!--end md-->

<script src="/static/www/js/comment.js"></script><!--点评效果-->
<script>
//textarea输入框限制字数
function keyAnum(obj){
	var len = $(obj).val().length;
	if (len > 500) {
		$("#ceiling").show();
		var num = $(obj).val().substring(0, 500);
		$(obj).val(num);
		return false;
	}
	else {
		$("#ceiling").hide();
		$("#word").text($(obj).val().length);
		return false;
	}
}

$("#submit").click(function(){
	var star = parseInt($(".rater-star-result").find("span").html());
	if(star <= 0 || isNaN(star)){
		layer.msg("请评分", {icon:5});
		return false;
	}
	var content = $("#content").val();
	if(content.length < 10){
		layer.msg("评论内容不能少于10个字符", {icon:5});
		return false;
	}
	if(!$(this).hasClass("submited")){
		$.ajax({
	    	type: "POST",
	    	url:  "/comment/save",
	    	data: "data_id=<{$data_id}>&data_type=<{$data_type}>&content="+content+"&star="+star,
	    	async: false,
	    	dataType: "json",
	    	success: function(data){
	    		$("#submit").addClass("submited");
	        	if(data == 0){
	        		layer.msg("评论失败，请重试", {icon:5});
	        		$("#submit").removeClass("submited");
	        	}else if(data == 1){
	        		parent.layer.msg("评论成功", {icon:6});
	        		var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
        			parent.layer.close(index);
	        	}else if(data == 9){
	        		parent.layer.msg("请登录", {icon:5});
	        		var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
        			parent.layer.close(index);
	        	}
	      	}
	    });
	}
	
})
</script>
</body>
</html>
